﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Customer_Profile.ClientManage
{
    public partial class CustomerDetail : System.Web.UI.Page
    {
        string page = "CustomerList.aspx";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["page"] != null)
            {
                this.page = "CustomerView.aspx";
            }
            if (Request.QueryString["Guid"] != null)
            {
                this.setmodel(Request.QueryString["Guid"].ToString());
            }
            else
            {
                Response.Redirect(page, false);
            }
        }

        private void setmodel(string guid)
        {
            try
            {
                Customer model = new Customer();
                CustomerDao da = new CustomerDao();
                model = da.GetModel(guid);
                this.lblbirthday.Text = model.Birthday;
                this.lbladdress.Text = model.Address;
                this.lbladvisor.Text = model.Advisor;
                this.lblcity.Text = model.City;
                this.lblcountry.Text = model.Country;
                this.lblcreatedate.Text = model.CreateDate.Date.ToString().Substring(0, model.CreateDate.Date.ToString().IndexOf(":") - 2);
                this.lblmodifieddate.Text = model.ModifyDate.Date.ToString().Substring(0, model.ModifyDate.Date.ToString().IndexOf(":") - 2);
                this.lblcsnno.Text = model.CSNNo;
                this.lblemail.Text = model.Email;
                this.lblfax.Text = model.FaxNo;
                this.lblfinno.Text = model.FINNo;
                this.lblfirstname.Text = model.FirstName;
                this.lblhometel.Text = model.HomeNo;
                this.lblibid.Text = model.IBID;
                this.lblibidloginname.Text = model.IBLoginName;
                this.lblphonepassword.Text = model.PhonePassword;
                this.lbllastname.Text = model.LastName;
                this.lbllocal.Text = model.Location;
                this.lblpostcode.Text = model.PostalCode;
                this.lblprovince.Text = model.RegionProvince;
                this.lblremarks.Text = model.Remarks;
                this.lblstatus.Text = model.Status;
                this.lbltitle.Text = model.Title;
                this.lblworktel.Text = model.WorkNo;
                this.lbAuthoriseAddress.Text = model.authorise_Address;
                this.lbAuthoriseBirth.Text = model.authorise_Birth;
                this.lbAuthoriseCity.Text = model.authorise_City;
                this.lbAuthoriseCountry.Text = model.authorise_Country;
                this.lbAuthoriseFirstName.Text = model.authorise_FirstName;
                this.lbAuthoriseHomeNo.Text = model.authorise_HomeNO;
                this.lbAuthoriseLastName.Text = model.authorise_LastName;
                this.lbAuthoriseProvince.Text = model.authorise_Province;
                this.lbauthorisetitle.Text = model.authorise_Title;
                this.lbAuthoriseWorkNo.Text = model.authorise_WorkNO;
            }
            catch (Exception ex)
            {
                KVB.Common.Log.WriteDefaultLog("setmodel", ex.ToString());
            }
        }

        protected void save_ServerClick(object sender, EventArgs e)
        {
            Response.Redirect(page, false);
        }
    }
}
